package com.study02;

public class RunnableDemo implements Runnable {
    private int tickets = 20;
    @Override
    public void run() {
        for(int i = 0; i < 25; i++){
            if(tickets >= 0){
                System.out.println(Thread.currentThread().getName() + "正在售票，剩余：" + this.tickets--);
            }else{
                System.out.println(Thread.currentThread().getName() + "票卖完了");
                break;  // 跳出循环体
            }
        }
    }
}
